//
//  SASendRecordCell.m
//  saasRetail
//
//  Created by mac on 2023/6/4.
//

#import "SASendRecordCell.h"
#import "UILabel+NSMutableAttributedString.h"
#import "SASmsSendRecordModel.h"

@interface SASendRecordCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIView *grayView;
@property (nonatomic, strong) UILabel *contentLab;

@property (nonatomic, strong) UILabel *stateLab;
@property (nonatomic, strong) UILabel *numLab;
@property (nonatomic, strong) UILabel *dateLab;

@end

@implementation SASendRecordCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SASmsSendRecordModel *)model {
    _model = model;
    self.titleLab.text = model.name;
    self.contentLab.text = model.content;
    self.numLab.text = [NSString stringWithFormat:@"共%@条",model.count];
    self.dateLab.text = [NSString stringWithFormat:@"发送时间 %@",model.createTime];
    
    if ([model.status isEqualToString:@"1"]) {
        self.stateLab.text = @"已发送";
    }else {
        self.stateLab.text = @"未发送";
    }
}


-(void)initUI {
    
    self.backgroundColor = kBgColor;
    [self.contentView addSubview:self.bgView];
    
    [self.bgView addSubview:self.line];
    [self.bgView addSubview:self.titleLab];
    
    [self.contentView addSubview:self.grayView];
    [self.grayView addSubview:self.contentLab];
    
    [self.contentView addSubview:self.stateLab];
    [self.contentView addSubview:self.numLab];
    [self.contentView addSubview:self.dateLab];
    
    [self.contentLab setLineSpace:5];
}

-(UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIImageView alloc] initWithFrame:SARectMake(10, 0, kBaseScreenWidth - 20, 126)];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = kScaleNum(5);
        _bgView.layer.masksToBounds = YES;
        _bgView.userInteractionEnabled = YES;
    }
    return _bgView;
}

-(UIView *)line {
    if (!_line) {
        _line = [[UIImageView alloc] initWithFrame:SARectMake(10, 10, 6, 18)];
        _line.backgroundColor = [UIColor redColor];
        _line.layer.cornerRadius = kScaleNum(3);
        _line.layer.masksToBounds = YES;
    }
    return _line;
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(26, 10, 200, 18)];
        _titleLab.font = kFont(15);
        _titleLab.textColor = kBlackColor;
        _titleLab.text = @"店庆活动";
    }
    return _titleLab;
}

-(UIView *)grayView {
    if (!_grayView) {
        _grayView = [[UIImageView alloc] initWithFrame:SARectMake(26, 37, 240, 50)];
        _grayView.userInteractionEnabled = YES;
        _grayView.layer.borderColor = kLightgGrayColor.CGColor;
        _grayView.layer.borderWidth = kScaleNum(1);
        _grayView.layer.cornerRadius = kScaleNum(5);
        _grayView.layer.masksToBounds = YES;
    }
    return _grayView;
}

-(UILabel *)contentLab {
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] initWithFrame:SARectMake(8, 0, 224, 50)];
        _contentLab.font = kFont(12);
        _contentLab.textColor = kGrayColor;
        _contentLab.text = @"";
        _contentLab.numberOfLines = 3;
    }
    return _contentLab;
}

-(UILabel *)stateLab {
    if (!_stateLab) {
        _stateLab = [[UILabel alloc] initWithFrame:SARectMake(kBaseScreenWidth - 150, 10, 130, 18)];
        _stateLab.font = kFont(15);
        _stateLab.textColor = kBlackColor;
        _stateLab.text = @"已发送";
        _stateLab.textAlignment = NSTextAlignmentRight;
    }
    return _stateLab;
}

-(UILabel *)numLab {
    if (!_numLab) {
        _numLab = [[UILabel alloc] initWithFrame:SARectMake(kBaseScreenWidth - 150, 38, 130, 48)];
        _numLab.font = kFont(15);
        _numLab.textColor = kBlackColor;
        _numLab.text = @"共30条";
        _numLab.textAlignment = NSTextAlignmentRight;
    }
    return _numLab;
}

-(UILabel *)dateLab {
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] initWithFrame:SARectMake(kBaseScreenWidth - 350, 86, 320, 40)];
        _dateLab.font = kFont(15);
        _dateLab.textColor = kBlackColor;
        _dateLab.text = @"发送时间 2022-01-01 12:12:12";
        _dateLab.textAlignment = NSTextAlignmentRight;
    }
    return _dateLab;
}

@end
